import { getUsersApi } from "@/api/users";
export default {
  data() {
    return {
      users: [],
      total: 0,
      params: {
        pagenum: 1,
        pagesize: 5,
        query: "",
      },
    };
  },
  methods: {
    // 获取用户列表
    getUsers(str) {
      if (str && typeof str === "string") {
        this.params.query = str;
      } else {
        this.params.query = "";
      }
      getUsersApi(this.params).then(({ data }) => {
        var { data } = data;
        this.total = data.total;
        this.params.pagenum = data.pagenum;
        this.users = data.users;
      });
    },
  },
  mounted() {
    this.getUsers();
  },
  components: {
    Header: () => import("./component/Header.vue"),
    Main: () => import("./component/Main.vue"),
    Pages: () => import("./component/Pages.vue"),
  },
};
